import { useIntersectionObserver } from "@vueuse/core"
import { ref } from "vue"

// 封装数据懒加载函数
export function useLazyData(callback:()=>void){
    const target = ref(null)
    const {stop}  = useIntersectionObserver(target,([{isIntersecting}])=>{
        if(isIntersecting){
            callback()
            stop()
        }
    },{
        threshold: 0   //阀值   dom或组件只要是在视口就要加载数据
    })

    return target
}

